﻿#region Copyright (C) Sector7 Software Studio. All rights reserved
/*******************************************************************************************
 * Creation
 *      Author:         Wolf Lai
 *      Date:           2013/5/19 星期日 19:44:01
 *      Version:        
 * Modification 
 *      Author: 
 *      Date: 
 *      Description: 
 *      Version:
 *******************************************************************************************/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using Sector7.Medical.EntityType;
using Sector7.Framework.DB;
using Sector7.Medical.Consts;

namespace Sector7.Medical.DAO.Standard
{
    /// <summary>
    /// 供货商数据访问对象
    /// </summary>
    public class VendorDAO : DAOBase<M7_Vendor>, IVendorDAO
    {
        #region Accessor
        #endregion

        #region Public functions
        public override object Create(M7_Vendor vendor)
        {
            string sql = @"
                INSERT INTO M7_Vendor
                        (VendorName
                        ,ContacterId
                        ,VendorPhone
                        ,VendorAddress
                        ,Remarks)
                    VALUES
                        (@VendorName
                        ,@ContacterId
                        ,@VendorPhone
                        ,@VendorAddress
                        ,@Remarks)
                SELECT @@IDENTITY";

            using (DBHelper helper = new DBHelper())
            {
                return helper.ExecuteNonQuery(sql,
                    DBUtil.CreateSqlParameter(vendor.VendorName, "VendorName"),
                    DBUtil.CreateSqlParameter(vendor.ContacterId, "ContacterId"),
                    DBUtil.CreateSqlParameter(vendor.VendorPhone, "VendorPhone"),
                    DBUtil.CreateSqlParameter(vendor.VendorAddress, "VendorAddress"),
                    DBUtil.CreateSqlParameter(vendor.Remarks, "Remarks"));
            }
        }
        #endregion

        #region Private functions
        #endregion

        #region Structure
        public VendorDAO()
        {
            m_tableName = C_M7_TableName.VENDOR;
            m_primaryKeyName = C_PrimaryKeyName.VENDOR_ID;
        }
        #endregion

        #region Inner members
        #endregion
    }
}
